package com.assessment.servermanager.service.impl;

import com.assessment.servermanager.entity.TbSalary;
import com.assessment.servermanager.mapper.TbSalaryMapper;
import com.assessment.servermanager.service.ITbSalaryService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 【请填写功能名称】Service业务层处理
 *
 * @author jiajia
 * @date 2023-08-28
 */
@Service
public class TbSalaryServiceImpl implements ITbSalaryService {
    @Autowired
    private TbSalaryMapper tbSalaryMapper;

    /**
     * 查询【请填写功能名称】
     *
     * @param id 【请填写功能名称】主键
     * @return 【请填写功能名称】
     */
    @Override
    public TbSalary selectTbSalaryById(Long id) {
        return tbSalaryMapper.selectById(id);
    }

    /**
     * 查询【请填写功能名称】列表
     *
     * @param tbSalary 【请填写功能名称】
     * @return 【请填写功能名称】
     */
    @Override
    public List<TbSalary> selectTbSalaryList(TbSalary tbSalary) {
        LambdaQueryWrapper<TbSalary> queryWrapper = new LambdaQueryWrapper<TbSalary>()
                .eq(tbSalary.getId() != null,TbSalary::getId,tbSalary.getId())
                .eq(tbSalary.getUid() != null,TbSalary::getUid,tbSalary.getUid())
                .eq(tbSalary.getJid() != null,TbSalary::getJid,tbSalary.getJid())
                .eq(tbSalary.getDid() != null,TbSalary::getDid,tbSalary.getDid())
                .eq(tbSalary.getSalary() != null,TbSalary::getSalary,tbSalary.getSalary());
        return tbSalaryMapper.selectList(queryWrapper);
    }

    /**
     * 新增【请填写功能名称】
     *
     * @param tbSalary 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int insertTbSalary(TbSalary tbSalary) {
        return tbSalaryMapper.insert(tbSalary);
    }

    /**
     * 修改【请填写功能名称】
     *
     * @param tbSalary 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int updateTbSalary(TbSalary tbSalary) {
        return tbSalaryMapper.updateById(tbSalary);
    }

    /**
     * 批量删除【请填写功能名称】
     *
     * @param ids 需要删除的【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deleteTbSalaryByIds(Long[] ids) {
        return tbSalaryMapper.deleteBatchIds(Arrays.stream(ids).collect(Collectors.toList()));
    }

    /**
     * 删除【请填写功能名称】信息
     *
     * @param id 【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deleteTbSalaryById(Long id) {
        return tbSalaryMapper.deleteById(id);
    }
}
